"use strict";
//科选参数必须放到最后
function getInfo(name, age) {
    if (age) {
        return name + "---" + age;
    }
    else {
        return name + "---\u5E74\u9F84\u4FDD\u5BC6";
    }
}
console.log(getInfo("wxs"));
//可选参数
function getInfo2(name, age) {
    if (age === void 0) { age = 30; }
    if (age) {
        return name + "---" + age;
    }
    else {
        return name + "---\u5E74\u9F84\u4FDD\u5BC6";
    }
}
console.log(getInfo2("wxs", 34));
//剩余参数
function sum(a, b, c, d) {
    return a + b + c + d;
}
console.log("===>", sum(1, 2, 3, 4));
function sum2() {
    var result = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        result[_i] = arguments[_i];
    }
    var sum = 0;
    for (var i = 0; i < result.length; i++) {
        sum += result[i];
    }
    return sum;
}
console.log(sum2(1, 1, 2, 2));
function sum3(a) {
    var result = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        result[_i - 1] = arguments[_i];
    }
    var sum = a;
    for (var i = 0; i < result.length; i++) {
        sum += result[i];
    }
    return sum;
}
console.log("剩余运算符:", sum3(1, 1, 2, 2));
function sum4(a, b) {
    var result = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        result[_i - 2] = arguments[_i];
    }
    var sum = a + b;
    for (var i = 0; i < result.length; i++) {
        sum += result[i];
    }
    return sum;
}
console.log("剩余运算符:", sum4(1, 1, 2, 2));
